package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(20);not null;comment:'商品名称'"`
	GoodsNum   int64   `gorm:"type:int;default:0;comment:'商品数量'"`
	GoodsImage string  `gorm:"type:varchar(225);not null;comment:'商品图标'"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);default:0.00;comment:'商品费用'"`
	GoodsLike  int64   `gorm:"type:int;default:0;comment:'点赞数量'"`
}

func (g *Goods) InFo(goodsId int64) error {
	return DB.Where("id =?", goodsId).Error
}

func (g *Goods) Find(Page, pageSize int64) (list []*Goods, err error) {
	err = DB.Offset(int((Page - 1) * pageSize)).Limit(int(pageSize)).Find(&list).Error
	return
}
